// background.js

// 定义颜色
let color = '#3aa757';

// 首次安装插件、插件更新、chrome浏览器更新时触发
chrome.runtime.onInstalled.addListener(() => {
	chrome.storage.sync.set({
		color
	});
});

// let IsOpen = true
chrome.runtime.onInstalled.addListener(() => {
	chrome.storage.sync.set({
		IsOpen: false
	});


});


// background.js

function test() {
	// let keywords = document.getElementById('keywords');
	// console.log(keywords);
}

chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {

	if (message === "test") {
		test();
		sendResponse(666)
	}
	if (message === "ExecuteIsOpen") {

		chrome.storage.sync.get('IsOpen', ({
			IsOpen
		}) => {
			let thisOpen = !IsOpen
			chrome.storage.sync.set({
				IsOpen: thisOpen
			});

			sendResponse(thisOpen);
		});
		return true
	}
});